
macro(source_group_by_dir dir source_files)
    if(MSVC)
        set(sgbd_cur_dir ${dir})
        foreach(sgbd_file ${source_files})
            string(REGEX REPLACE ${sgbd_cur_dir}/\(.*\) \\1 sgbd_fpath ${sgbd_file})
            string(REGEX REPLACE "\(.*\)/.*" \\1 sgbd_group_name ${sgbd_fpath})
            string(COMPARE EQUAL ${sgbd_fpath} ${sgbd_group_name} sgbd_nogroup)
            string(REPLACE "/" "\\" sgbd_group_name ${sgbd_group_name})
            if(sgbd_nogroup)
                set(sgbd_group_name "\\")
            endif(sgbd_nogroup)
            source_group(${sgbd_group_name} FILES ${sgbd_file})
        endforeach(sgbd_file)
    endif(MSVC)
endmacro(source_group_by_dir)

function(git_clone url path version) #克隆指定版本
    if(version)
        execute_process(COMMAND git clone -b version --depth=1 ${url} ${path})
    else()
        execute_process(COMMAND git clone ${url} ${path})
    endif()
endfunction()